package com.tz.online.user.action;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.tz.online.entity.User;
import com.tz.online.user.service.IUserService;
import com.tz.online.util.BeanFactory;

/**
 * 接收用户提交的注册请求
 * @author Administrator
 *
 */
@WebServlet(name="register",urlPatterns="/user/register")
public class RegisterAction extends HttpServlet {
	/**
	 * 
	 */
	private static final long serialVersionUID = -123527932732714290L;
	IUserService us = (IUserService) BeanFactory.getBean("userService");
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		User user = new User();
		user.setUsername(req.getParameter("username"));
		user.setPassword(req.getParameter("password"));
		user.setEmail(req.getParameter("email"));
		user.setTel(req.getParameter("tel"));
		user.setAddress(req.getParameter("address"));
		user.setComparate(req.getParameter("corparate"));
		//接收用户信息，封装用户对象
		us.registerUser(user);
		
		resp.sendRedirect(req.getContextPath()+"/jsp/user/login.jsp");
	}
	
}
